package com.lijiajia.cloud.common.core.pojo;

import org.springframework.data.domain.Pageable;

import java.util.List;

/**
 * custom {@code Page} implementation.
 *
 * @param <T> the type of which the page consists.
 * @author lijiajia
 * @since 2019-4-26
 */
public class CustomPage<T> extends org.springframework.data.domain.PageImpl<T> {

    public CustomPage(List<T> content, Pageable pageable, long total) {
        super(content, pageable, total);
    }

    public CustomPage(List<T> content) {
        super(content);
    }

    /**
     * 有上一页
     * 页码从 1 开始
     *
     * @return 是否有上一页
     */
    @Override
    public boolean hasPrevious() {
        return getNumber() > 1;
    }
}
